All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.JCheckBoxMenuItem
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----com.sun.java.swing.JComponent
|
+----com.sun.java.swing.AbstractButton
|
+----com.sun.java.swing.JMenuItem
|
+----com.sun.java.swing.JCheckBoxMenuItem
- public class JCheckBoxMenuItem
- extends JMenuItem
- implements SwingConstants, Accessible
A menu item that can be selected or deselected. If selected, the menu
item typically appears with a checkmark next to it. If unselected or
deselected, the menu item appears without a checkmark. Like a regular
menu item, a checkbox menu item can have either text or a graphic
icon associated with it, or both.
Either isSelected
/setSelected
or
getState
/setState
can be used
to determine/specify the menu item's selection state. (The
Swing-standard methods are isSelected
and
setSelected
. These methods work for all menus and buttons.
The getState
and setState
methods exist for
compatibility with other component sets.)
For the keyboard keys used by this component in the standard Look and
Feel (L&F) renditions, see the
JCheckBoxMenuItem key assignments.
Warning: serialized objects of this class will not be compatible with
future swing releases. The current serialization support is appropriate
for short term storage or RMI between Swing1.0 applications. It will
not be possible to load serialized Swing1.0 objects with future releases
of Swing. The JDK1.2 release of Swing will be the compatibility
baseline for the serialized form of Swing objects.
-
JCheckBoxMenuItem()
- Creates an initially unselected checkboxMenuItem with no set text or icon.
-
JCheckBoxMenuItem(Icon)
- Creates an initially unselected checkboxMenuItem with an icon.
-
JCheckBoxMenuItem(String)
- Creates an initially unselected checkboxMenuItem with text.
-
JCheckBoxMenuItem(String, boolean)
- Creates a checkboxMenuItem with the specified text and selection state.
-
JCheckBoxMenuItem(String, Icon)
- Creates an initially unselected checkboxMenuItem with the specified text and icon.
-
JCheckBoxMenuItem(String, Icon, boolean)
- Creates a checkboxMenuItem with the specified text, icon, and selection state.
-
getAccessibleContext()
- Get the AccessibleContext associated with this JComponent
-
getSelectedObjects()
- Returns an array (length 1) containing the checkbox menu item
label or null if the checkbox is not selected.
-
getState()
- Returns the selected-state of the item.
-
getUIClassID()
- Returns the name of the L&F class
that renders this component.
-
init(String, Icon)
- Initialize the menu item with the specified text and icon.
-
requestFocus()
- Set focus on the receiving component if isRequestFocusEnabled returns true
-
setState(boolean)
- Sets the selected-state of the item.
-
setUI(CheckBoxMenuItemUI)
- Sets L&F object that renders this component.
-
updateUI()
- Notification from the UIFactory that the L&F
has changed.
JCheckBoxMenuItem
public JCheckBoxMenuItem()
- Creates an initially unselected checkboxMenuItem with no set text or icon.
JCheckBoxMenuItem
public JCheckBoxMenuItem(Icon icon)
- Creates an initially unselected checkboxMenuItem with an icon.
- Parameters:
- icon - the icon of the CheckBoxMenuItem.
JCheckBoxMenuItem
public JCheckBoxMenuItem(String text)
- Creates an initially unselected checkboxMenuItem with text.
- Parameters:
- text - the text of the CheckBoxMenuItem
JCheckBoxMenuItem
public JCheckBoxMenuItem(String text,
Icon icon)
- Creates an initially unselected checkboxMenuItem with the specified text and icon.
- Parameters:
- text - the text of the CheckBoxMenuItem
- icon - the icon of the CheckBoxMenuItem
JCheckBoxMenuItem
public JCheckBoxMenuItem(String text,
boolean b)
- Creates a checkboxMenuItem with the specified text and selection state.
- Parameters:
- text - the text of the CheckBoxMenuItem.
- b - the selected state of the checkboxmenuitem
JCheckBoxMenuItem
public JCheckBoxMenuItem(String text,
Icon icon,
boolean b)
- Creates a checkboxMenuItem with the specified text, icon, and selection state.
- Parameters:
- text - the text of the CheckBoxMenuItem
- icon - the icon of the CheckBoxMenuItem
- b - the selected state of the checkboxmenuitem
init
protected void init(String text,
Icon icon)
- Initialize the menu item with the specified text and icon.
- Overrides:
- init in class JMenuItem
setUI
public void setUI(CheckBoxMenuItemUI ui)
- Sets L&F object that renders this component.
- Parameters:
- ui - the new L&F object CheckBoxMenuItemUI
- See Also:
- getUI
updateUI
public void updateUI()
- Notification from the UIFactory that the L&F
has changed.
- Overrides:
- updateUI in class JMenuItem
- See Also:
- updateUI
getUIClassID
public String getUIClassID()
- Returns the name of the L&F class
that renders this component.
- Returns:
- "CheckBoxMenuItemUI"
- Overrides:
- getUIClassID in class JMenuItem
- See Also:
- getUIClassID, getUI
getState
public boolean getState()
- Returns the selected-state of the item. This method
exists for AWT compatibility only. New code should
use isSelected() instead.
- Returns:
- true if the item is selected
setState
public synchronized void setState(boolean b)
- Sets the selected-state of the item. This method
exists for AWT compatibility only. New code should
use setSelected() instead.
- Parameters:
- b - a boolean value indicating the item's
selected-state, where true=selected
getSelectedObjects
public synchronized Object[] getSelectedObjects()
- Returns an array (length 1) containing the checkbox menu item
label or null if the checkbox is not selected.
- Returns:
- an array containing 1 Object -- the text of the menu item
-- if the item is selected, otherwise null
- Overrides:
- getSelectedObjects in class AbstractButton
requestFocus
public void requestFocus()
- Set focus on the receiving component if isRequestFocusEnabled returns true
- Overrides:
- requestFocus in class JComponent
getAccessibleContext
public AccessibleContext getAccessibleContext()
- Get the AccessibleContext associated with this JComponent
- Returns:
- the AccessibleContext of this JComponent
- Overrides:
- getAccessibleContext in class JMenuItem
All Packages Class Hierarchy This Package Previous Next Index